package com.example.leetdemo.finash;

import java.util.Arrays;

public class Solution2294 {

    public int partitionArray(int[] nums, int k) {
        Arrays.sort(nums);
        int count = 0;
        int p = 0;
        for (int i = 1; i < nums.length; i++) {
            int a = nums[i] - nums[p];
            if (a > k) {
                count++;
                p = i;
            }
        }
        if (count == 0) {
            return 1;
        }
        return count + 1;
    }

}
